//
//  XQAlertController.m
//  JoinPeso
//
//  Created by 小琦 on 2024/11/28.
//

#import "XQAlertController.h"

@implementation XQAlertController

+ (void)showAccessDeniedAlert:(UIViewController *)controller message:(nonnull NSString *)message{
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Access Denied"
                                                                   message:message
                                                            preferredStyle:UIAlertControllerStyleAlert];

    UIAlertAction *settingsAction = [UIAlertAction actionWithTitle:@"Settings"
                                                           style:UIAlertActionStyleDefault
                                                         handler:^(UIAlertAction * _Nonnull action) {
        // 打开应用的设置
        NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
        if ([[UIApplication sharedApplication] canOpenURL:url]) {
            [[UIApplication sharedApplication] openURL:url options:@{} completionHandler:nil];
        }
    }];
    
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
                                                           style:UIAlertActionStyleCancel
                                                         handler:nil];
    
    [alert addAction:settingsAction];
    [alert addAction:cancelAction];
    
    [controller presentViewController:alert animated:YES completion:nil];
}


@end
